/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package view;

import Model.Anggota;
import Model.Perpustakaan;
import java.awt.event.ActionEvent;
import java.util.ArrayList;
import javax.swing.*;
import javax.swing.JPanel;

/**
 *
 * @author SMK N 2 PENGASIH
 */
public class PanelCariAnggota extends JPanel{
    private JLabel labelPanel;
    private JTextArea areaAnggota;
    private JTextField cariAnggota;
    private JButton cari;
    
    public PanelCariAnggota(){
        setLayout(null);
        
    labelPanel = new JLabel("Masukkan nama : ");
            labelPanel.setBounds(30, 15, 100, 30);
            add(labelPanel);
            
            cariAnggota=new JTextField();
            cariAnggota.setBounds(140, 15, 150, 30);
            add(cariAnggota);
            
            cari=new JButton("cari");
            cari.setBounds(300, 15, 100, 30);
            add(cari);
            
            cari.addActionListener(new java.awt.event.ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                tombolCariAction();
            }
        });

            areaAnggota = new JTextArea();
            areaAnggota.setBounds(100, 50, 300, 250);
            add(areaAnggota);
            setVisible(true);
 }
    public void tombolCariAction(){
        Perpustakaan.bacaTabelAnggota();
        ArrayList<Anggota>test4=Perpustakaan.cariAnggota(cariAnggota.getText());
        for (int i = 0; i < test4.size(); i++) {
            String temp = "";
            temp = " Nama : " +test4.get(i).getNama()+"\n id : "+test4.get(i).getIdAnggota();
            areaAnggota.setText(temp);
            
        }
    }
}